﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace qip_history_synchronizer
{
    class Message
    {
        public enum TYPE
        {
            IN,
            OUT
        }

        public TYPE M_TYPE;
        public string MESSAGE;
        public string CONTACT;
        public DateTime DATE;

        public Message(TYPE type, DateTime date, string contact, string message)
        {
            this.M_TYPE = type;
            this.DATE = date;
            this.CONTACT = contact;
            this.MESSAGE = message;
        }

        public override bool Equals( object obj )
        {
            Message compareObj = ( Message ) obj;
            if(this.CONTACT == compareObj.CONTACT
               && this.DATE == compareObj.DATE
               && this.M_TYPE == compareObj.M_TYPE
               && this.MESSAGE == compareObj.MESSAGE)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public bool ContaisInList( List<Message> messages )
        {
            var equals = from mess in messages
                         where mess.Equals( this )
                         select mess;
            
            if(equals.Count()>0)
                return true;
            return false;
        }
    }
}